<?php

namespace app\admin\controller;


use app\admin\model\AdminAuthGroup;
use app\admin\model\AdminMenu;
use app\admin\service\AdminGroupService;
use app\admin\service\AdminMenuService;
use app\common\attributes\Menu;
use think\annotation\Inject;

class MenuController extends AdminBaseController
{
    #[Inject]
    protected AdminMenuService $service;

    #[Inject]
    protected AdminMenu $model;
    #[Menu('查看菜单列表')]
    public function index()
    {
        $data = $this->getParams();
        //当前是否为关联查询
        //设置过滤方法
        $extendQueryHelper = $this->buildparams();
        $list = $this->service->cmsList($extendQueryHelper, $data);
        foreach ($list as $row) {

        }
        return $this->success($list);

    }

    /**
     * 添加菜单
     */
    #[Menu('添加菜单')]
    public function save()
    {
    	$request = $this->getParams();
        $result = AdminMenuService::cmsAdd($request);
        return  $this->returnSuccess( $result);
    }

    /**
     * 菜单详情
     * @param $id
     */
    #[Menu('菜单详情')]
    public function read($menu_id)
    {
        $result = AdminMenuService::cmsDetail($menu_id);
        return  $this->returnSuccess( $result);
    }

    /**
     * 修改菜单
     * @param $id
     */
    #[Menu('修改菜单')]
    public function update($menu_id)
    {
	    $request = $this->getParams();

        $result = AdminMenuService::cmsEdit($request);

        return  $this->returnSuccess( $result);
    }

    /**
     * 删除菜单
     * @param $id
     */
    #[Menu('删除菜单')]
    public function delete($menu_id)
    {

        $result = AdminMenuService::cmsDelete($menu_id);

        return  $this->returnSuccess( $result);
    }


}
